package org.lyricedit.domain;

public enum Phoneme {

	//monophthongs
	ɔ("AO","ɔ",true), //off (AO1 F); fall (F AO1 L); frost (F R AO1 S T)
	ɑ("AA","ɑ",true), //father (F AA1 DH ER), cot (K AA1 T)
	i("IY","i",true),//	bee (B IY1); she (SH IY1)
	u("UW","u",true),//	you (Y UW1); new (N UW1); food (F UW1 D)
	ɛ("EH","ɛ",true),//	red (R EH1 D); men (M EH1 N)
	ɪ("IH","ɪ",true),//	big (B IH1 G); win (W IH1 N)
	ʊ("UH","ʊ",true),//	should (SH UH1 D), could (K UH1 D)
	ʌ("AH","ʌ",true),//	but (B AH1 T), sun (S AH1 N)
	ə("AH","ə",true),//	but (B AH1 T), sun (S AH1 N)
	æ("AE","æ",true),//	at (AE1 T); fast (F AE1 S T)
	//dipthongs
	eɪ("EY","eɪ",true),//	say (S EY1); eight (EY1 T)
	aɪ("AY","aɪ",true),//	my (M AY1); why (W AY1); ride (R AY1 D)
	oʊ("OW","oʊ",true),//	show (SH OW1); coat (K OW1 T)
	aʊ("AW","aʊ",true),//	how (HH AW1); now (N AW1)
	ɔɪ("OY","ɔɪ",true),//	boy (B OY1); toy (T OY1)
	//r-colored
	ɝ("ER","ɝ",true),//	her (HH ER0); bird (B ER1 D); hurt (HH ER1 T), nurse (N ER1 S)
	ɚ("ER","ɚ",true),//	father (F AA1 DH ER); coward (K AW1 ER D)
	
	//Stops
	p("P","p",false),//	pay (P EY1)
	b("B","b",false),//	buy (B AY1)
	t("T","t",false),//	take (T EY1 K)
	d("D","d",false),//	day (D EY1)
	k("K","k",false),//	key (K IY1)
	ɡ("G","ɡ",false),//	go (G OW1)
	
	//Affricates
	tʃ("CH","tʃ",false),//	chair (CH EH1 R)
	dʒ("JH","dʒ",false),//	just (JH AH1 S T); gym (JH IH1 M)

	//Fricatives
	f("F","f",false),//	for (F AO1 R)
	v("V","v",false),//	very (V EH1 R IY0)
	θ("TH","θ",false),//	thanks (TH AE1 NG K S); Thursday (TH ER1 Z D EY2)
	ð("DH","ð",false),//	that (DH AE1 T); the (DH AH0); them (DH EH1 M)
	s("S","s",false),//	say (S EY1)
	z("Z","z",false),//	zoo (Z UW1)
	ʃ("SH","ʃ",false),//	show (SH OW1)
	ʒ("ZH","ʒ",false),//	measure (M EH1 ZH ER0); pleasure (P L EH1 ZH ER)
	h("HH","h",false),//	house (HH AW1 S)
	
	//Nasals
	m("M","m",false),//	man (M AE1 N)
	n("N","n",false),//	no (N OW1)
	ŋ("NG","ŋ",false),//	sing (S IH1 NG)
	
	//Liquids
	l("L","l",false),//	late (L EY1 T)
	r("R","r",false),// or ɹ	run (R AH1 N)
	
	//Semivowels
	j("Y","j",false),//	yes (Y EH1 S)
	w("W","w",false),//	way (W EY1)
	ʍ("HW","ʍ",false),//	"when" etc. in some dialects
	;
	
	final String arpabet;
	final String ipa;
	final boolean vowel;
	
	private Phoneme(String arpabet,String ipa,boolean vowel) {
		this.arpabet = arpabet;
		this.ipa = ipa;
		this.vowel =vowel;
	}
	
	public Phoneme fromIpa(String ipa){
		return valueOf(ipa);
	}
	
	public static Phoneme fromArpabet(String arpa){
		
		for (Phoneme phoneme : values()){
			if (phoneme.arpabet.equalsIgnoreCase(arpa))
				return phoneme;
		}
		
		throw new IllegalArgumentException("Unknown arpabet phoneme: " + arpa);
	}

	public String getArpabet() {
		return arpabet;
	}

	public String getIpa() {
		return ipa;
	}

	public boolean isVowel() {
		return vowel;
	}
	
	
}
